how to delete file in python

32

open('file.txt', 'w').close()
import os
os.remove("ChangedFile.csv")
print("File Removed!")
import os
os.remove("/tmp/<file_name>.txt")
import os

# os.remove("text.txt")
# print("File deleted")


for file in os.listdir("fileDirectory"):
    os.remove("fileDirectory"+file)
    print(file, "deleted")

Comments

Submit
0 Comments